*Replication file for Rikhil R. Bhavnani and Bethany Lacina, 2018, Nativism and Economic Integration across the Developing World, Cambridge University Press. Figure 7 & 8, Table 8.

global controls lnigdppercapppp lpop lpopden

qui reg lmigto $controls
capture drop sample
gen sample=e(sample)

*Figures 7 & 8
preserve
	reg lriots_mixed lmigto if sample==1
	capture drop temp	
	gen temp=e(sample)
	keep if temp==1
	
	*bivariate graph: Figure 7
	twoway (scatter lriots_mixed lmigto) || (lfit lriots_mixed lmigto, lpattern(solid) xtitle("{it:Ln} internal migrants") ytitle("{it:Ln} 1+riots")), legend(off) title("") note("") 
	
	*bivariate graphs by country: Figure 8
	local n=0
	foreach country in "Burkina Faso" "Cambodia" "Cameroon" "Egypt" "Ghana" "Guinea" "India" "Kenya" "Malawi" "Malaysia" "Mali" "Morocco" "Rwanda" "Senegal" "Sudan" "Tanzania" "Thailand" "Tunisia" "Uganda" "Vietnam" "Zambia" {
		local n=`n'+1
		twoway (scatter lriots_m lmigto if e(sample) & country=="`country'") || (lfit lriots_m lmigto if e(sample) & country=="`country'", lpattern(solid) xtitle("{it:Ln} internal migrants") ytitle("{it:Ln} 1+riots")), legend(off) title("`country'") note("") name(g`n', replace)
	}
restore

*Table 8

*Model 1
areg lriots_mixed lmigto if sample==1, a(cid) cl(cid)

*Model 2
areg lriots_during lmigto  if sample==1, a(cid) cl(cid)

*Model 3
areg lriots_mixed lmigto $controls [aw=weight], a(cid) cl(cid)

*Model 4
areg lriots_during lmigto $controls [aw=weight] , a(cid) cl(cid)

*Model 5
areg lriots_mixed lmigpoldecentA0 lmigpoldecentA1 $controls [aw=weight] , a(cid) cl(cid)
test lmigpoldecentA1=lmigpoldecentA0

*Model 6
areg lriots_during lmigpoldecentA0 lmigpoldecentA1 $controls [aw=weight], a(cid) cl(cid)
test lmigpoldecentA1=lmigpoldecentA0

